<template>
  <approve-common v-bind="$attrs" v-on="$listeners" :related-data="relatedData">
    <div slot="before">
      <table class="table table-sm table-bordered approve-table">
        <colgroup>
          <col width="20%" />
          <col width="30%" />
          <col width="20%" />
          <col width="30%" />
        </colgroup>
        <tbody>
          <tr>
            <td>评审附件</td>
            <td colspan="3" class="text-left">
              <el-button type="text" @click="handleDueReportView">调查报告</el-button>
              <el-button type="text" @click="handleRiskView">风险审查报告</el-button>
              <el-button type="text" @click="handleAttachView">项目附件</el-button>
            </td>
          </tr>
        </tbody>
      </table>

      <el-dialog
        :visible.sync="attachVisible"
        :close-on-click-modal="false"
        append-to-body
        top="30px"
        width="1000px"
      >
        <attach-view :queryId="attachQueryId" :visible="attachVisible"></attach-view>
      </el-dialog>

      <due-report :visible.sync="dueReportVisible" :query-id="dueReportId" view-mode></due-report>

      <risk-report :visible.sync="riskVisible" :query-id="riskQueryId" view-mode></risk-report>
    </div>
  </approve-common>
</template>

<script>
import AttachView from '@/credit/components/AttachView'
import DueReport from '@/credit/views/county/unionProvince/components/dueReport/MainDialog'
import RiskReport from '@/credit/views/county/unionProvince/components/riskReport/Dialog'
import ApproveCommon from '@/credit/views/county/unionProvince/components/projectApprove/ApproveCommon'

export default {
  components: {
    AttachView,
    DueReport,
    RiskReport,
    ApproveCommon,
  },
  props: {
    relatedData: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      // 尽调报告
      dueReportVisible: false,
      dueReportId: '',

      // 项目附件
      attachVisible: false,
      attachQueryId: '',

      // 风险审查报告
      riskVisible: false,
      riskQueryId: '',
    }
  },
  computed: {
    relatedId() {
      return this.relatedData.customer_related_id
    },
  },
  watch: {},
  created() {},
  mounted() {},
  methods: {
    handleDueReportView() {
      this.dueReportId = this.relatedId
      this.dueReportVisible = true
    },

    handleAttachView() {
      this.attachQueryId = this.relatedId
      this.attachVisible = true
    },

    handleRiskView() {
      this.riskQueryId = this.relatedId
      this.riskVisible = true
    },
  },
}
</script>

<style lang="scss" scoped>
@import './index.scss';
</style>
